package cn.edu.bupt.scidata.mapper;

import cn.edu.bupt.scidata.model.paper.Fund;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface PaperFund {
    //    根据两学科查询项目列表
    @Select("SELECT fund.number,fund.title,fund.money,fund.type,DATE_FORMAT( fund.starttime, \"%Y\" ) AS starttime,DATE_FORMAT( fund.endtime, \"%Y\" ) AS endtime FROM fund WHERE id IN ( SELECT fund_id from paper_fd WHERE paper_id in (SELECT b.paper_id  FROM paper_clf b INNER JOIN paper_clf a FORCE INDEX ( paper_clf_paper_id_classify_id_0e86387a_uniq ) ON a.paper_id = b.paper_id  AND a.classify_id = #{a_id}  AND b.classify_id = #{b_id} GROUP BY b.paper_id))")
//        @Select("SELECT * FROM fund WHERE id IN(SELECT fund_id FROM paper_fd WHERE paper_id IN (SELECT a.paper_id FROM paper_clf a left JOIN paper_clf b ON a.paper_id = b.paper_id WHERE a.classify_id = #{a_id} AND b.classify_id = #{b_id})) and money is NOT NULL")
    List<Fund> queryfund(int a_id, int b_id);
}
